import request from '@/utils/axios';

import { OrganizationVO, OrgTreeNode } from './types';

export const listApi = () => {
  return request.post<OrganizationVO[]>({ url: '/system/organization/list' });
};

export const getApi = (id: string) => {
  return request.get<OrganizationVO>({ url: '/system/organization/get/' + id });
};

export const getFullPathApi = (id: string) => {
  return request.get<string>({ url: '/system/organization/getFullPath/' + id });
};

export const saveApi = (data: OrganizationVO) => {
  return request.post({ url: '/system/organization/save', data });
};

export const updateApi = (data: OrganizationVO) => {
  return request.post({ url: '/system/organization/update', data });
};

export const removeApi = (id?: string) => {
  return request.post({ url: '/system/organization/remove', params: { id } });
};

export const listValidTreeNodeApi = () => {
  return request.get<OrgTreeNode[]>({
    url: '/system/organization/listValidTreeNode',
  });
};
